package org.leetcode.easy.leetcode257;

import org.leetcode.TreeNode;

import java.util.ArrayList;
import java.util.List;

public class Solution
{

    List<String> result = new ArrayList<>();


    public List<String> binaryTreePaths(TreeNode root)
    {

        deal(root,"");

        return result;
    }

    public void deal(TreeNode node, String s) {

        if (node.left == null && node.right == null) {
            result.add(new StringBuilder(s).append(node.val).toString());
            return;
        }
        String tmp = new StringBuilder(s).append(node.val).append("->").toString();
        deal(node.left, tmp);
        deal(node.right, tmp);
    }

    public static void main(String[] args) {

    }
}
